package com.sjr.easy.chat.app.config;

import com.sjr.easy.chat.app.ws.AppTextWebSocketHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.socket.config.annotation.EnableWebSocket;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;

@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
    @Autowired
    private AppTextWebSocketHandler appTextWebSocketHandler;

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(appTextWebSocketHandler, "/app/ws/notify")
                .setAllowedOrigins("*");
    }
}
